<%@ page language="java" import="javax.*,java.util.*,component.student.*,course.*,user.*" pageEncoding="UTF-8"%>
<%@ include file="SessionCheck.jsp"%>
<%
Course course=(Course)session.getAttribute("course");
String cid=course.getCid();
String n=request.getParameter("chapter");
String filename="c:/upload/"+cid+"/chapter"+n+".swf";
String id=student.getId();
MessageHandle handle=new MessageHandle(id);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title><%=course.getCname()%></title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<script type="text/javascript" src="fsplayer.js"></script>
	<script type="text/javascript" src="swfobject.js"></script>
</head>
<body>
	  
      <div align="left"></div>
      <table width="921" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutDefaultTable-->
        <tr>
          <td width="133" height="76"><p align="center">
          <a href="learning.jsp?chapter=<%=Integer.parseInt(n)-1%>">上一章</a>
          <a href="learning.jsp?chapter=<%=Integer.parseInt(n)+1%>">下一章</a></p>
          <input name="goprev" type="button" id="goprev" value="转到上次学习的终点" onclick="javascript:go()"/></td>
          <td width="788"><div align="center" id="movieArea"/></td>
        </tr>
      </table>
	          <script type="text/javascript">
		var pc = null;
		var filename=null;
		var loader = new fsplayer.api.PresentationLoader();
		loader.onPlayerInit = function(player)
		{
			pc = player.getPlaybackController();
			pc.enableAllEventHandlers();
		}


		function loadPresentation(str)
		{
			filename=str;
			loader.load(str, "movieArea", "newPlayerId",900,600);
		}
		
		
		
if(typeof(XMLHttpRequest)=="undefined" && window.ActiveXObject)
{
	function XMLHttpRequest()
	{
		var xmlhttp_arr=["MSXML2.XMLHTTP","Microsoft.XMLHTTP"];
		var xml_request;
		for(var i=0;i<xmlhttp_arr.length;i++)
		{
			if(xml_request = new ActiveXObject(xmlhttp_arr[i]))
			break;
		}
		return xml_request;
	}
}
function add_param(paras_str,param_name,param_value)
{
	paras_str += (paras_str.length>0) ? "&" : "";
	paras_str += param_name + "=" + param_value;
	return paras_str;
}

var xml_http_request = new XMLHttpRequest();
function send_post()
{
	var url = "<%=path%>/handleServlet";
	paras = "";
	var tempindex=pc.getCurrentSlideIndex();
	paras = add_param(paras,"index",tempindex);
	paras = add_param(paras,"file","<%=filename %>");
	paras = add_param(paras,"classname","<%=cid%>");
	xml_http_request.open("POST",url,true);
	xml_http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xml_http_request.send(paras);
	return;
}
	loadPresentation("<%=filename %>");
	setInterval("send_post()",5000);
	function go()
	{
		<%
			int index=handle.getPage(filename);
			out.print("pc.gotoSlide("+index+",true);");
		%>
	}
	
	  </script>
</body>
</html>
